home *** CD-ROM | disk | FTP | other *** search
/ Champak 142 / Volume 142 Oct 17 2011 - Damaged.iso / Games / maya-ball.swf / scripts / __Packages / bonus.as < prev    next >
Text File  |  2011-10-17  |  8KB  |  196 lines

  1. class bonus extends MovieClip
  2. {
  3.    function bonus()
  4.    {
  5.       super();
  6.       _global.bonusez.push(this);
  7.       this.w = this._width / 2;
  8.       this.h = this._height / 2;
  9.       this.init = false;
  10.       this._alpha = 0;
  11.       trace("create bonus: " + this);
  12.    }
  13.    function initObj(t, s)
  14.    {
  15.       s = parseFloat(s);
  16.       if(_global.noSet(s))
  17.       {
  18.          return undefined;
  19.       }
  20.       this.type = t;
  21.       this.speedy = s;
  22.       this.init = true;
  23.    }
  24.    function onEnterFrame()
  25.    {
  26.       if(_global.gameInMoving)
  27.       {
  28.          if(this.init)
  29.          {
  30.             if(this._alpha < 100)
  31.             {
  32.                this._alpha += 10;
  33.                if(this._alpha > 100)
  34.                {
  35.                   this._alpha = 100;
  36.                }
  37.             }
  38.             this._y += this.speedy;
  39.             if(this._y > 450)
  40.             {
  41.                this.removeFromArray();
  42.                this.removeMovieClip();
  43.             }
  44.          }
  45.          if(_global.gameInProcess)
  46.          {
  47.             if(this.hitTest(_global.player))
  48.             {
  49.                if(this.type != "bomb")
  50.                {
  51.                   _global.sound.play("bonpick",this._x);
  52.                }
  53.                if(this.type == "triple")
  54.                {
  55.                   var _loc4_ = _global.ballz[Math.floor(Math.random() * _global.ballz.length)];
  56.                   if(_loc4_.type == "rocket" || _loc4_.type == "lazer" || _loc4_.type == "freeze")
  57.                   {
  58.                   }
  59.                   var _loc8_ = Math.atan2(_loc4_.yspeed,_loc4_.xspeed);
  60.                   var _loc6_ = _root.all.blz.attachMovie("ballContainer","ballMC" + _root.all.blz.getNextHighestDepth(),_root.all.blz.getNextHighestDepth());
  61.                   var _loc7_ = _loc8_ - _global.envS.bonus_ball_ang / _global.PI2;
  62.                   _loc6_.initObj("simpleBall",_loc4_.speedDefault * Math.cos(_loc7_),_loc4_.speedDefault * Math.sin(_loc7_));
  63.                   _loc6_.moveTo(_loc4_._x,_loc4_._y);
  64.                   _loc6_.setMode(_loc4_.mode,_loc4_.modeChangedTime,_loc4_.modeChangedMaxTime);
  65.                   _loc6_.changeSpeed(_loc4_.speedRatio,_loc4_.speedChangedTime,_loc4_.speedChangedMaxTime);
  66.                   _loc6_.changeDim(_loc4_.dimRatio,_loc4_.dimChangedTime,_loc4_.dimChangedMaxTime);
  67.                   _loc6_.image._xscale = _loc6_.image._yscale = _loc4_.image._xscale;
  68.                   _loc6_.inQueue(50);
  69.                   _global.ballz.push(_loc6_);
  70.                   _loc6_ = _root.all.blz.attachMovie("ballContainer","ballMC" + _root.all.blz.getNextHighestDepth(),_root.all.blz.getNextHighestDepth());
  71.                   _loc7_ = _loc8_ + _global.envS.bonus_ball_ang / _global.PI2;
  72.                   _loc6_.initObj("simpleBall",_loc4_.speedDefault * Math.cos(_loc7_),_loc4_.speedDefault * Math.sin(_loc7_));
  73.                   _loc6_.moveTo(_loc4_._x,_loc4_._y);
  74.                   _loc6_.setMode(_loc4_.mode,_loc4_.modeChangedTime,_loc4_.modeChangedMaxTime);
  75.                   _loc6_.changeSpeed(_loc4_.speedRatio,_loc4_.speedChangedTime,_loc4_.speedChangedMaxTime);
  76.                   _loc6_.changeDim(_loc4_.dimRatio,_loc4_.dimChangedTime,_loc4_.dimChangedMaxTime);
  77.                   _loc6_.image._xscale = _loc6_.image._yscale = _loc4_.image._xscale;
  78.                   _loc6_.inQueue(50);
  79.                   _global.ballz.push(_loc6_);
  80.                }
  81.                else if(this.type == "live")
  82.                {
  83.                   _global.changePlayerLives(1);
  84.                }
  85.                else if(this.type == "lazer" || this.type == "rocket" || this.type == "freeze")
  86.                {
  87.                   _global.player.setMode(this.type,_global.envS[this.type + "Count"]);
  88.                }
  89.                else if(this.type == "acid" || this.type == "fire")
  90.                {
  91.                   var _loc5_ = 0;
  92.                   while(_loc5_ < _global.ballz.length)
  93.                   {
  94.                      _global.ballz[_loc5_].setMode(this.type);
  95.                      _loc5_ = _loc5_ + 1;
  96.                   }
  97.                }
  98.                else if(this.type == "glue")
  99.                {
  100.                   _global.player.glued = true;
  101.                   _global.player.gluedChangedTime = 0;
  102.                   _global.player.gluedChangedMaxTime = _global.envS.glueTime;
  103.                   _global.player.img.glue._visible = true;
  104.                }
  105.                else if(this.type == "slowball")
  106.                {
  107.                   _loc5_ = 0;
  108.                   while(_loc5_ < _global.ballz.length)
  109.                   {
  110.                      _global.ballz[_loc5_].changeSpeed(_global.envS.speedChangeDown);
  111.                      _loc5_ = _loc5_ + 1;
  112.                   }
  113.                }
  114.                else if(this.type == "fastball")
  115.                {
  116.                   _loc5_ = 0;
  117.                   while(_loc5_ < _global.ballz.length)
  118.                   {
  119.                      _global.ballz[_loc5_].changeSpeed(_global.envS.speedChangeUp);
  120.                      _loc5_ = _loc5_ + 1;
  121.                   }
  122.                }
  123.                else if(this.type == "bigball")
  124.                {
  125.                   _loc5_ = 0;
  126.                   while(_loc5_ < _global.ballz.length)
  127.                   {
  128.                      _global.ballz[_loc5_].changeDim(_global.envS.dimChangeUp);
  129.                      _loc5_ = _loc5_ + 1;
  130.                   }
  131.                }
  132.                else if(this.type == "littleball")
  133.                {
  134.                   _loc5_ = 0;
  135.                   while(_loc5_ < _global.ballz.length)
  136.                   {
  137.                      _global.ballz[_loc5_].changeDim(_global.envS.dimChangeDown);
  138.                      _loc5_ = _loc5_ + 1;
  139.                   }
  140.                }
  141.                else if(this.type == "widecaret")
  142.                {
  143.                   _global.player.rchangeDim(_global.player_caret.maxWidth);
  144.                }
  145.                else if(this.type == "narrowcaret")
  146.                {
  147.                   _global.player.rchangeDim(_global.player_caret.minWidth);
  148.                }
  149.                else if(this.type == "bomb")
  150.                {
  151.                   _global.changePlayerLives(-1,true);
  152.                }
  153.                else if(this.type == "wall")
  154.                {
  155.                   if(!_global.noSet(_global.wallTile))
  156.                   {
  157.                      _global.wallTile.decreaseLive(- _global.envS.wallBonusLives);
  158.                   }
  159.                   else
  160.                   {
  161.                      var _loc9_ = _root.all.top1.getNextHighestDepth();
  162.                      _global.wallTile = _root.all.top1.attachMovie("tileMC","tt" + _loc9_,_loc9_);
  163.                      _global.wallTile.makeTile("theWall");
  164.                      _global.allTiles.unshift(_global.wallTile);
  165.                      _global.wallTile.setInGame(0);
  166.                      _global.wallTile.setLives(_global.envS.wallBonusLives);
  167.                      _global.wallTile._x = 0;
  168.                      _global.wallTile._y = _global.borders.bottom - 10;
  169.                      _global.wallTile.initObj();
  170.                   }
  171.                }
  172.                else if(this.type == "score")
  173.                {
  174.                   _global.changeLevelScore(_global.envS.bonusScore);
  175.                }
  176.                this.removeFromArray();
  177.                this.removeMovieClip();
  178.             }
  179.          }
  180.       }
  181.    }
  182.    function removeFromArray()
  183.    {
  184.       var _loc3_ = 0;
  185.       while(_loc3_ < _global.bonusez.length)
  186.       {
  187.          if(_global.bonusez[_loc3_] == this)
  188.          {
  189.             _global.bonusez.splice(_loc3_,1);
  190.             return undefined;
  191.          }
  192.          _loc3_ = _loc3_ + 1;
  193.       }
  194.    }
  195. }
  196.